/**
 * Copyright © 2014 TingerSure. All rights reserved.
 */
package org.sure.scomet.action;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.sure.scomet.link.Connection;
import org.sure.scomet.link.ConnectionCenter;
import org.sure.scomet.util.log.LogManager;
import org.sure.scomet.util.log.LogType;

public class RequestAction {

	public void Action(HttpServletRequest req, HttpServletResponse res) {
		Connection conn = new Connection();
		int pageId = ConnectionCenter.addConnection(conn);
		try {
			PrintWriter write = res.getWriter();
			write.write("r:" + pageId);
		} catch (IOException e) {
			LogManager.logException(
					"An error occurred while connecting created!", e,
					LogType.error);
		}
		ConnectionCenter.getCallBack().LinkedCallBack(pageId, req.getSession());
	}

}
